//Magnus Baunsgaard Kristensen s140168
//Jonathan Yannick Thomassen s125070

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

public class NumeriskPanel extends JPanel {

  Konsol ejer;

  JButton button0 = new JButton();
  JButton button1 = new JButton();
  JButton button2 = new JButton();
  JButton button3 = new JButton();
  JButton button4 = new JButton();
  JButton button5 = new JButton();
  JButton button6 = new JButton();
  JButton button7 = new JButton();
  JButton button8 = new JButton();
  JButton button9 = new JButton();
  JButton buttonOk = new JButton();
  JButton buttonDel = new JButton();

  public NumeriskPanel(Konsol k) {
    try {
      init();
    } catch (Exception e) {
    }
    ejer = k;
  }

  private void init() throws Exception {
    button0.setText("0");
    button1.setText("1");
    button2.setText("2");
    button3.setText("3");
    button4.setText("4");
    button5.setText("5");
    button6.setText("6");
    button7.setText("7");
    button8.setText("8");
    button9.setText("9");
    buttonOk.setText("OK");
    buttonDel.setText("←");

    button1.setBounds(10, 10, 75, 75);
    button2.setBounds(95, 10, 75, 75);
    button3.setBounds(180, 10, 75, 75);
    button4.setBounds(10, 95, 75, 75);
    button5.setBounds(95, 95, 75, 75);
    button6.setBounds(180, 95, 75, 75);
    button7.setBounds(10, 180, 75, 75);
    button8.setBounds(95, 180, 75, 75);
    button9.setBounds(180, 180, 75, 75);
    buttonDel.setBounds(10, 265, 75, 75);
    button0.setBounds(95, 265, 75, 75);
    buttonOk.setBounds(180, 265, 75, 75);

    this.setLayout(null);
    this.add(button0);
    this.add(button1);
    this.add(button2);
    this.add(button3);
    this.add(button4);
    this.add(button5);
    this.add(button6);
    this.add(button7);
    this.add(button8);
    this.add(button9);
    this.add(buttonOk);
    this.add(buttonDel);

    button0.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button0_actionPerformed(e);
      }
    });

    button1.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button1_actionPerformed(e);
      }
    });

    button2.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button2_actionPerformed(e);
      }
    });

    button3.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button3_actionPerformed(e);
      }
    });

    button4.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button4_actionPerformed(e);
      }
    });

    button5.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button5_actionPerformed(e);
      }
    });

    button6.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button6_actionPerformed(e);
      }
    });

    button7.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button7_actionPerformed(e);
      }
    });

    button8.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button8_actionPerformed(e);
      }
    });

    button9.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        button9_actionPerformed(e);
      }
    });

    buttonOk.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonOk_actionPerformed(e);
      }
    });

    buttonDel.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonDel_actionPerformed(e);
      }
    });
  }

  void button0_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(0);
  }

  void button1_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(1);
  }

  void button2_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(2);
  }

  void button3_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(3);
  }

  void button4_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(4);
  }

  void button5_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(5);
  }

  void button6_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(6);
  }

  void button7_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(7);
  }

  void button8_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(8);
  }

  void button9_actionPerformed(ActionEvent e) {
    ejer.numeriskInput(9);
  }

  void buttonOk_actionPerformed(ActionEvent e) {
    ejer.numeriskInput("ok");
  }

  void buttonDel_actionPerformed(ActionEvent e) {
    ejer.numeriskInput("del");
  }
}
